@extends('layouts.admin')
@section('css')
    <link href="{{asset('vendors/dataTables/datatables.min.css')}}" rel="stylesheet">
    <link rel="stylesheet" href="{{asset('vendors/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css')}}">
@endsection
@section('content')
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>{{$activity->name}}</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="{{url('admin/dash')}}">{!!trans('admin/breadcrumb.home')!!}</a>
                </li>
                <li>
                    <a href="{{url('admin/eticket/activity')}}">{!!trans('admin/breadcrumb.ticket.list')!!}</a>
                </li>
                <li class="active">
                    <strong><i class="fa fa-ticket"></i> 门票设置</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>线上门票</h5>
                        <div class="ibox-tools">
                            <button id="billing-btn" class="btn btn-sm btn-warning"><i class="fa fa-bell"></i> 手动开票</button>
                            <button id="add-tickets-btn" data-toggle="modal" data-target="#online-add-tickets-modal"
                                    class="btn btn-sm btn-info"><i class="fa fa-plus"></i> 添加门票
                            </button>
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        @include('flash::message')
                        <div class="form-inline setting" data-way="{{\App\Models\Eticket\Ticket::ONLINE}}">
                            <div class="form-group">
                                <label for="start-date">开抢时间：</label>
                                <input id="start_date" type="text" class="form-control date-input" value="{{isset($activity->online->start_date)?date('Y-m-d H:i',$activity->online->start_date):''}}">
                            </div>
                            <div class="form-group">
                                <label for="end-date">截止时间：</label>
                                <input id="end_date" type="text" class="form-control date-input" value="{{isset($activity->online->end_date)?date('Y-m-d H:i',$activity->online->end_date):''}}">
                            </div>
                            <div class="form-group">
                                <label for="billing-date">开票时间：</label>
                                <input id="billing_date" type="text" class="form-control date-input" value="{{isset($activity->online->billing_date)?date('Y-m-d H:i',$activity->online->billing_date):''}}">
                            </div>
                            <div class="checkbox">
                                <label>
                                    <input id="other_school" type="checkbox" {{$activity->online && $activity->online->other_school==1?'checked':''}}> 允许其他学校抢票
                                </label>
                            </div>
                        </div>
                        <br>
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover dataTablesAjax"
                                   data-way="{{\App\Models\Eticket\Ticket::ONLINE}}">
                                <thead>
                                <tr>
                                    <th>票种</th>
                                    <th>总数</th>
                                    <th>剩余</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>线下派票</h5>
                        <div class="ibox-tools">
                            <button id="add-tickets-btn" data-toggle="modal" data-target="#offline-add-tickets-modal"
                                    class="btn btn-sm btn-info"><i class="fa fa-plus"></i> 添加门票
                            </button>
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        @include('flash::message')
                        <div class="form-inline setting" data-way="{{\App\Models\Eticket\Ticket::OFFLINE}}">
                            <div class="form-group">
                                <label for="start-date">开抢时间：</label>
                                <input id="start_date" type="text" class="form-control date-input" value="{{isset($activity->offline->start_date)?date('Y-m-d H:i',$activity->offline->start_date):''}}">
                            </div>
                            <div class="form-group">
                                <label for="end-date">截止时间：</label>
                                <input id="end_date" type="text" class="form-control date-input" value="{{isset($activity->offline->end_date)?date('Y-m-d H:i',$activity->offline->end_date):''}}">
                            </div>
                            <div class="checkbox">
                                <label>
                                    <input id="other_school" type="checkbox" {{$activity->offline && $activity->offline->other_school==1?'checked':''}}> 允许其他学校抢票
                                </label>
                            </div>
                        </div>
                        <br>
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover dataTablesAjax"
                                   data-way="{{\App\Models\Eticket\Ticket::OFFLINE}}">
                                <thead>
                                <tr>
                                    <th>票种</th>
                                    <th>总数</th>
                                    <th>剩余</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade add-tickets-modal" id="online-add-tickets-modal" tabindex="-1" role="dialog"
         aria-labelledby="online-add-tickets-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">线上抢票——增加门票</h4>
                </div>
                <div class="modal-body">
                    <div class="alert alert-warning" role="alert">如果无座位号，请在无号个数直接填写座位个数；<br>如果有座位号，请上传Excel格式的文件，第一行为表头，第二行以下为座位号！<br><b>注意：当无号和有号都有值时，都将会导入数据库</b>
                    </div>
                    <form class="form-horizontal add-tickets-form">
                        {{csrf_field()}}
                        <input type="hidden" name="way" value="{{\App\Models\Eticket\Ticket::ONLINE}}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.type')}}</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="type" id="tickets-type"
                                       placeholder="{{trans('act/ticket.ticket.type')}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.noNumber')}}</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="noNumber" id="tickets-noNumber"
                                       placeholder="{{trans('act/ticket.ticket.noNumber')}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.file')}}</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="file" id="tickets-file"
                                       placeholder="{{trans('act/ticket.ticket.file')}}">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">{{trans('admin/action.actionButton.close')}}</button>
                    <button type="button" class="btn btn-primary add-tickets-ok-btn"
                            data-way="{{\App\Models\Eticket\Ticket::ONLINE}}">{!! trans('admin/action.actionButton.submit')!!}</button>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade add-tickets-modal" id="offline-add-tickets-modal" tabindex="-1" role="dialog"
         aria-labelledby="offline-add-tickets-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">线下派票——增加门票</h4>
                </div>
                <div class="modal-body">
                    <div class="alert alert-warning" role="alert">如果无座位号，请在无号个数直接填写座位个数；<br>如果有座位号，请上传Excel格式的文件，第一行为表头，第二行以下为座位号！<br><b>注意：当无号和有号都有值时，都将会导入数据库</b>
                    </div>
                    <form class="form-horizontal add-tickets-form">
                        {{csrf_field()}}
                        <input type="hidden" name="way" value="{{\App\Models\Eticket\Ticket::OFFLINE}}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.type')}}</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="type" id="tickets-type"
                                       placeholder="{{trans('act/ticket.ticket.type')}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.noNumber')}}</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="noNumber" id="tickets-noNumber"
                                       placeholder="{{trans('act/ticket.ticket.noNumber')}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">{{trans('act/ticket.ticket.file')}}</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="file" id="tickets-file"
                                       placeholder="{{trans('act/ticket.ticket.file')}}">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">{{trans('admin/action.actionButton.close')}}</button>
                    <button type="button" class="btn btn-primary add-tickets-ok-btn"
                            data-way="{{\App\Models\Eticket\Ticket::OFFLINE}}">{!! trans('admin/action.actionButton.submit')!!}</button>
                </div>
            </div>
        </div>
    </div>

    <!-- QRCode Modal -->
    <div class="modal fade qrcode-modal" id="offline-qrcode-modal" tabindex="-1" role="dialog"
         aria-labelledby="offline-qrcode-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">线下派票——二维码</h4>
                </div>
                <div class="modal-body" style="text-align: center">
                    <div class="panel panel-default">
                        <div class="panel-body qrcode-url"></div>
                    </div>
                    <div><img class="qrcode-img" src="" alt=""></div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('js')
    <script src="{{asset('vendors/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js')}}"></script>
    <script src="{{asset('vendors/dataTables/datatables.min.js')}}"></script>
    <script src="{{asset('vendors/layer/layer.js')}}"></script>
    <script src="{{asset('admin/js/eticket/ticket-datatable.js')}}"></script>
    <script type="text/javascript">
        $(document).on('click', '.destroy_item', function () {
            var _item = $(this);
            var title = "{{trans('admin/alert.deleteTitle')}}";
            layer.confirm(title, {
                btn: ['{{trans('admin/action.actionButton.destroy')}}', '{{trans('admin/action.actionButton.no')}}'],
                icon: 5
            }, function (index) {
                _item.children('form').submit();
                layer.close(index);
            });
        });
    </script>
@endsection